public class Solution713 {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
        long cur=1;
        int j=0;
        int ans=0;
        for (int i=0;i<nums.length;i++){
            cur=cur*nums[i];
            while (j<=i && cur>=k){
                cur=cur/nums[j];
                j++;
            }
            ans=ans+i-j+1;
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution713().numSubarrayProductLessThanK(new int[]{10,5,2,6},100));
    }
}
